#include <opencv2/core.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main(int argc,char *argv[])
{
    Mat PB=Mat::ones(3,1,CV_32FC1);
    Mat R=Mat::ones(3,3,CV_32FC1);
    Mat PA;
    Mat C=Mat::ones(3,1,CV_32FC1);

    PB.at<float>(0,0)=1;
    PB.at<float>(1,0)=2;
    PB.at<float>(2,0)=0;


    R.at<float>(0,0)=0.866;
    R.at<float>(0,1)=-0.5;
    R.at<float>(0,2)=0;
    R.at<float>(1,0)=0.5;
    R.at<float>(1,1)=0.866;
    R.at<float>(1,2)=0;
    R.at<float>(2,0)=0;
    R.at<float>(2,1)=0;
    R.at<float>(2,2)=1;

    PA=R.t()*PB;
    cout<<"----------------------------------------------第1题-----------------------------------------------------"<<endl;
    cout<<"PB=\n"<<PB<<endl<<endl;
    cout<<"R=\n"<<R<<endl<<endl;
    cout<<"PA=\n"<<PA<<endl<<endl;

    C.at<float>(0,0)=2;
    C.at<float>(1,0)=-3;
    C.at<float>(2,0)=1;
    PA=PB-C;
    cout<<"----------------------------------------------第2题-----------------------------------------------------"<<endl;
    cout<<"PA=\n"<<C<<endl<<endl;

    R.at<float>(0,0)=0.707;
    R.at<float>(0,1)=0;
    R.at<float>(0,2)=0.707;
    R.at<float>(1,0)=0;
    R.at<float>(1,1)=1;
    R.at<float>(1,2)=0;
    R.at<float>(2,0)=-0.707;
    R.at<float>(2,1)=0;
    R.at<float>(2,2)=0.707;
    PA=R*PB;
    cout<<"----------------------------------------------第3题-----------------------------------------------------"<<endl;
    cout<<"R=\n"<<R<<endl<<endl;
    cout<<"PA=\n"<<PA<<endl<<endl;

    R.at<float>(0,0)=1;
    R.at<float>(0,1)=0;
    R.at<float>(0,2)=0;
    R.at<float>(1,0)=0;
    R.at<float>(1,1)=0.866;
    R.at<float>(1,2)=-0.5;
    R.at<float>(2,0)=0;
    R.at<float>(2,1)=0.5;
    R.at<float>(2,2)=0.866;

    PA=R.t()*PB;
    cout<<"----------------------------------------------第4题-----------------------------------------------------"<<endl;
    //cout<<"PB=\n"<<PB<<endl<<endl;
    cout<<"R=\n"<<R<<endl<<endl;
    cout<<"PA=\n"<<PA<<endl<<endl;
}